package com.cheer.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * 用户信息
 * 
 * @author cheer
 */
@Data
@TableName("oa_user")
@Accessors(chain = true)
public class OaUserEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 
	 */
	@TableId
	private Integer id;
	/**
	 * 姓名
	 */
	private String name;
	/**
	 * 
	 */
	private String nickname;
	/**
	 * 
	 */
	private String headimgurl;
	/**
	 * 性别
	 */
	private Integer sex;
	/**
	 * 
	 */
	private String type;
	/**
	 * 政治面貌
	 */
	private String politicsStatus;
	/**
	 * 出生日期
	 */
	private String birthTime;
	/**
	 * 
	 */
	private String openid;
	/**
	 * 
	 */
	private String path;
	/**
	 * 籍贯
	 */
	private String nativePlace;
	/**
	 * 积分
	 */
	private Integer integral;
	/**
	 * 小红花
	 */
	private Integer flower;
	/**
	 * 
	 */
	private Integer useIntegral;
	/**
	 * 职业
	 */
	private String profession;
	/**
	 * 
	 */
	private String department;
	/**
	 *
	 */
	private String phone;
	/**
	 * 
	 */
	private String addTime;
	/**
	 * 
	 */
	private String updataTime;


	/**
	 * 获取可兑换积分
	 * @return
	 */
	public Integer getShopCredit() {

		if (this.getUseIntegral() == null) {
			return this.getIntegral();
		} else {
			return this.getIntegral() - this.getUseIntegral();
		}
	}

	public Integer ableGetFlower( Integer creditRadio ){
		return getShopCredit() / creditRadio;
	}
	/**
	 * 获取可兑换积分
	 * @return
	 */
	public void addIntegral( Integer addIntegral ) {
		Integer current = this.getIntegral() + addIntegral;
		this.setIntegral(current);
	}

	/**
	 * 消耗小红花
	 * @return
	 */
	public void addFlower( Integer addFlower ) {
		Integer flower = this.getFlower() + addFlower;
		this.setFlower(flower);
	}


	/**
	 * 消耗小红花
	 * @return
	 */
	public void consumeFlower( Integer decFlower ) {
		Integer flower = this.getFlower() - decFlower;
		this.setFlower(flower);
	}


}
